//
//  StatusForwardCell.swift
//  weibo
//
//  Created by cmh on 15/9/8.
//  Copyright © 2015年 cmh. All rights reserved.
//

import UIKit

// 转发的微博
class StatusForwardCell: StatusCell {
    
    override var statusRowViewModel: StatusRowViewModel? {
        didSet{
            
            forwardLabel.text = statusRowViewModel?.forwordText
            
        }
    }
    
    // 设置控件，重写父类的方法
    override func setupUI() {
        
        super.setupUI()
        
        // 添加控件
        contentView.insertSubview(backGroundBtn, belowSubview: pictureView)
        contentView.insertSubview(forwardLabel, aboveSubview: backGroundBtn)
        
        // 设置自动布局
        // 背景按钮
        backGroundBtn.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: centerText, size: nil, offset: CGPoint(x: -statusCellMargin, y: statusCellMargin))
        backGroundBtn.ff_AlignVertical(type: ff_AlignType.TopRight, referView: bottomView, size: nil)
        
        // 转发微博文字
        forwardLabel.ff_AlignInner(type: ff_AlignType.TopLeft, referView: backGroundBtn, size: nil, offset: CGPoint(x: statusCellMargin, y: statusCellMargin))
        
        // 配图
        let cons = pictureView.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: forwardLabel, size: CGSize(width: statusCellPictureMaxWidth, height: statusCellPictureMaxWidth), offset: CGPointMake(0, statusCellMargin))

        pictureViewWidth = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Width)
        pictureViewHeight = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Height)
        pictureViewTop = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Top)
        
    }

    // 懒加载控件
    // 转发微博的背景按钮
    lazy private var backGroundBtn: UIButton = {
    
        let btn = UIButton()
        
        btn.backgroundColor = UIColor(white: 0.9, alpha: 1.0)
        
        return btn
        
    }()
    
    // 转发微博的原始文字
    lazy private var forwardLabel: UILabel = UILabel(title: "hello World ! hello World ! hello World ! hello World ! hello World ! hello World ! hello World ! hello World ! hello World ! hello World !  ", color: UIColor.darkGrayColor(), fontSize: 14, layoutWidth: UIScreen.mainScreen().bounds.width - 2 * statusCellMargin)

}
